#============================================================
#    Skill Test
#============================================================
# - datetime: 2022-11-24 21:44:32
#============================================================
extends Node2D


@onready 
var skill_data = %skill_data as DataManagement
@onready 
var skill_monitor = %skill_data_monitor as SkillDataMonitor



func _set_skill_data(data: Dictionary):
	print(data)
	var skill = skill_monitor.get_skill_by_data(data)
	for p in SkillConstants.get_propertys():
		if data.has(p):
			skill[p] = data[p]


func _ready():
	skill_data.newly_added_property.connect(func(skill_name, data: Dictionary): _set_skill_data(data) )
	skill_data.property_changed.connect(func(property, previous, current): _set_skill_data(current) )
	
	skill_data.add_property("技能1", {
		SkillConstants.Propertys.DURATION_TIME: 1
	})
	
	skill_monitor.connect_execute_after(func():
		print("1. 调用优先级为 5 的对象")
	, 5)
	skill_monitor.connect_execute_after(func():
		print("2. 调用优先级为默认值 10 的对象")
	)
	skill_monitor.connect_execute_after(func():
		print("3. 调用优先级为 1 的对象")
	, 1)
	skill_monitor.connect_execute_after(func():
		print("4. 调用优先级为 1 的对象")
	, 2)
	
	
	# 施放技能
	skill_monitor.cast_skill("技能1")
	


